package com.example.airhockeytextured.program

import android.content.Context
import android.opengl.GLES20.*

/**
 * @author Liujianyou
 * @date 2020/8/7
 * @des
 */
class ColorShaderProgram(
    context: Context,
    vertexShaderResourceId: String,
    fragmentShaderResourcesId: String
) : ShaderProgram(context, vertexShaderResourceId, fragmentShaderResourcesId) {
    private val uMatrixLocation by lazy { glGetUniformLocation(program, U_MATRIX) };
    private val aPositionLocation by lazy { glGetAttribLocation(program, A_POSITION) }
    private val aColorLocation by lazy { glGetAttribLocation(program, A_COLOR) }

    fun setUniforms(matrix: FloatArray) {
        glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0)
    }

    fun getPositionAttributeLocation(): Int {
        return aPositionLocation
    }

    fun getColorAttributeLocation(): Int {
        return aColorLocation
    }
}